<script setup lang="ts">
import { ref } from "vue"
const items = ref([
  {
    name: "项目1",
    count: 1,
    price: 10,
    subtotal: 10
  },
  {
    name: "项目2",
    count: 2,
    price: 20,
    subtotal: 40
  }
])

const total = ref(0)
const dialogTableVisible = ref(false)

const showClick = (el: any) => {
  console.log(el)
  dialogTableVisible.value = true
}
defineExpose({ showClick })
</script>

<template>
  <el-dialog v-model="dialogTableVisible" draggable destroy-on-close width="80%" title="收据" append-to-body>
    <h1 style="text-align: center">工商服务业统一收款依据</h1>
    <div class="stub" style="display: flex">
      <div>
        <!-- 占位符 -->
        &nbsp;
      </div>
      <div style="text-align: center">存根联</div>
      <img src="@/assets/bill/no.png" alt="" srcset="" />
    </div>

    <table>
      <thead>
        <tr>
          <th>项目</th>
          <th>数量</th>
          <th>单价</th>
          <th>小计</th>
        </tr>
      </thead>
      <tbody>
        <tr v-for="(item, index) in items" :key="index">
          <td>{{ item.name }}</td>
          <td>{{ item.count }}</td>
          <td>{{ item.price }}</td>
          <td>{{ item.subtotal }}</td>
        </tr>
      </tbody>
    </table>
    <div>
      <h3>总计：{{ total }}</h3>
    </div>
  </el-dialog>
</template>
<style scoped lang="scss">
.stub {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-bottom: 10px;
  img {
    width: 30px;
  }
}
table {
  width: 100%;
  border-collapse: collapse;
  border-spacing: 0;
  font-size: 14px;
  thead {
    background-color: #f5f7fa;
    th {
      padding: 10px;
      border: 1px solid #ebeef5;
    }
  }
  tbody {
    tr {
      td {
        padding: 10px;
        border: 1px solid #ebeef5;
      }
    }
  }
}
</style>
